#include <bits/stdc++.h>
using namespace std;

const int N = 8005;

int n, q;
int a[N], b[N];
int pre[N], now[N];

int main()
{
	freopen("sort.in", "r", stdin);
	freopen("sort.out", "w", stdout);

	scanf("%d%d", &n, &q);
	
	for (int i = 1; i <= n; i++)
	{
		scanf("%d", &a[i]);
		b[i] = a[i];
		pre[i] = now[i] = i;
	}
		
	for (int i = 1; i <= n; i++)
		for (int j = i; j >= 2; j--)
		{
			if (b[j] < b[j - 1])
			{
				swap(b[j], b[j - 1]);
				swap(now[pre[j]], now[pre[j - 1]]);
				swap(pre[j], pre[j - 1]);
			}
			else if (b[j] == b[j - 1])
			{
				if (pre[j] < pre[j - 1])
				{
					now[pre[j]] = j - 1;
					now[pre[j - 1]] = j;
					swap(pre[j], pre[j - 1]);
				}
			}
		}
		
	while (q--)
	{
		int op, x, val;
		
		scanf("%d%d", &op, &x);
		
		if (op == 1)
		{
			scanf("%d", &val);
			
			b[now[x]] = val;
			
			if (val < a[x])
				for (int j = n; j >= 2; j--)
				{
					if (b[j] < b[j - 1])
					{
						swap(b[j], b[j - 1]);
						swap(now[pre[j]], now[pre[j - 1]]);
						swap(pre[j], pre[j - 1]);
					}
					else if (b[j] == b[j - 1])
					{
						if (pre[j] < pre[j - 1])
						{
							now[pre[j]] = j - 1;
							now[pre[j - 1]] = j;
							swap(pre[j], pre[j - 1]);
						}
					}
				}
			else
				for (int j = 2; j <= n; j++)
				{
					if (b[j] < b[j - 1])
					{
						swap(b[j], b[j - 1]);
						swap(now[pre[j]], now[pre[j - 1]]);
						swap(pre[j], pre[j - 1]);
					}
					else if (b[j] == b[j - 1])
					{
						if (pre[j] < pre[j - 1])
						{
							now[pre[j]] = j - 1;
							now[pre[j - 1]] = j;
							swap(pre[j], pre[j - 1]);
						}
					}
				}
			
			a[x] = val;
		}
		else
			printf("%d\n", now[x]);
	}
	
	return 0;
}
